<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta name="decorator" content="sysDefault" />
<script type="text/javascript" src="${staticPath}/js/list.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$("#btnQuery").click(function(){
		$("#salesForm").submit();
	});
	$(".o-a-form-date").datetimepicker({
		language : 'zh-CN',
		autoclose : true,
		minView : 2,
		todayBtn : 1,
		pickerPosition : "bottom-left"
	});
});

/* function expurgate(){  //批量删除日志
	var month = $("#month").val();
	var year = $("#year").val();
	if(year!=null&&year!=''){
		var checkYear = /^\d{4}$/; //判断由4位数字组成
		if(!checkYear.test(year)){
			$("#year").val('');
			return false;
		}
	}
	else{
		alert("请输入年份");
		return false;
	}
	
	if(month!=null&&month!=''){
		var checkMonth = /^(0?[1-9]|1[0-2])$/;  //判断为01-09  1-12的数字
		if(checkMonth.test(month)){
			var path = '${contextPath}/sys/log/expurgate?month='+month+'&year='+year;
			if(Oosp_Confirm('确认要删除'+year+'年'+month+'月份日志吗？',path)){			
				return true;
			}
		}
		else{
			alert("请输入1-12之间的月份");
			$("#month").val('');
		}
	}
	else{
		alert("请输入月份");
	}
} */

function expurgate(){
	var deleteDate = $("#deleteDate").val();
	var year ='';
	var month = '';
	if(deleteDate ==''||deleteDate == null){
		alert("请选择需要删除的月份");
		return false;
	}else{
		var list = deleteDate.split("-");
		year = list[0];
		month = list[1];
	}	
	var path = '${contextPath}/sys/log/expurgate?year='+year+'&month='+month;
	if(Oosp_Confirm('确认要删除'+year+'年'+month+'月份日志吗？',path)){			
		return true;
	}
}
</script>

</head>
<body>
<form:form name="listForm"  modelAttribute="sysLog" method="post" class="form-inline" role="form">					  
	<div class="container-fluid">
		<div class="row">
			<div class="col-xs-12" style="margin-left:-15px;">
				<div class="panel panel-default">
				  <div class="panel-heading">
					  <h3 class="panel-title">
						      系统日志
					  </h3>
				  </div>
				  <div class="f_2" style="margin:5px;">		  
					  <div class="form-group">
							<form:input path="uri" id="uri" class="form-control" placeholder="操作URI" />
					  </div>
					  <div class="form-group">
						    <form:input path="operateName" id="operateName" class="form-control" placeholder="操作人" />
					  </div>
				  </div>  
				  <div class="f_2" style="margin:5px;" >
					  <div>
	           				<label style="font-size:13px;float:left;margin-top:7px;">创建时间：</label>
	                       	<div style="float:left;width:30%;margin-bottom:5px;" class="input-group date o-a-form-date" data-date="" data-date-format="yyyy-mm-dd">
							<input class="form-control" id="createTime" name="createTime"  value="<fmt:formatDate value="${sysLog.createTime}" pattern="yyyy-MM-dd"/>" type="text" readonly/>
								<span class="input-group-addon"><i class="glyphicon glyphicon-remove"></i></span>
								<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
							</div>
				      </div>
				      <div style="width:55px;height:35px;float:left;margin-left:10px;"><button class="btn btn-primary" type="submit">查询</button></div>
			          <div style="float:right;width:300px;">
			      		<div style="float:left;width:180px;margin-bottom:5px;margin-right:5px;" class="input-group date o-a-form-date" data-date="" data-date-format="yyyy-mm">
						<input class="form-control" id="deleteDate" type="text" readonly/>
							<span class="input-group-addon"><i class="glyphicon glyphicon-remove"></i></span>
							<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
						</div>
					    <button class="btn btn-primary" type="button" onclick="expurgate()">按月批量删除</button>
			      	  </div>
			      </div>										 
				  <tags:message content="${message}" />
		          <table class="table table-striped table-bordered table-hover">
						<thead>
						</thead>
						<thead>
							<tr>								
								<th>操作人</th>
								<th>创建时间</th>
								<th>操作IP</th>
								<th>操作URI</th>
								<th width="75px;">操作</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${page.list}" var="sysLog">
								<tr>	
									<td>${sysLog.operateName}</td>
									<td><fmt:formatDate value="${sysLog.createTime}"
									pattern="yyyy-MM-dd HH:mm:ss" /></td>
									<td>${sysLog.ip}</td>	
									<td>${sysLog.uri}</td>				  														
									<td>
										<a href="${contextPath}/sys/log/${sysLog.id}/view">查看</a>
										<a href="${contextPath}/sys/log/${sysLog.id}/delete"
										   onclick="return Oosp_Confirm('确认要删除该条数据吗？', this.href)">删除</a>
									</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				  <div class="panel-footer">
				  	<pager:pager pageSize="${page.pageSize}" pageNo="${page.pageNo}" url="" total="${page.total}"/>
				  </div>
				</div>			
			</div>
		</div>
	</div>
</form:form>
</body>
</html>